<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

Auth::routes();

Route::get('/home', 'HomeController@index');

// 基本路由
Route::get('hello', function () {
    return 'Hello, Masaka9!';
});

// 路由参数 - 必选参数
Route::get('hello/{name}', function ($name) {
    return 'Hello, ' . $name . '!';
});

// 路由参数 - 可选参数
Route::get('hello2/{name?}', function ($name = 'maojie') {
    return 'Hello, ' . $name . '!';
});

// 命名路由
Route::get('hi', ['as' => 'hi', function () {
    return 'hi';
}]);

Route::get('hi/{name}', function ($name) {
    return 'hi, ' . $name . '!';
})->name('hi2');

// 为命名路由生成URL
Route::get('test', function () {
    return route('hi');
//    return route('hi2', ['name' => 'maojie']);
});

Route::resource('demos', 'DemoController');

Route::get('getAuthUser', 'TestController@getAuthUser')->middleware('auth');
Route::get('getAuthUser2', 'TestController@getAuthUser2')->middleware('auth');
Route::get('authCheck', 'TestController@authCheck');

Route::get('dbtest', 'DBDemoController@test');